﻿using System.Data;
using System.Data.SqlClient;

namespace MyWeb.Data
{
    public class GroupProductController : SqlDataProvider
    {
        #region [GroupProduct_GetByAll]

        public DataTable GroupProduct_GetByAll()
        {
            return GetDataTable("sp_GroupProduct_GetByAll");
        }

        #endregion

        #region [GroupProduct_GetById]

        public DataTable GroupProduct_GetById(int id)
        {
            var p1 = new SqlParameter("@id", id);
            return GetDataTable("sp_GroupProduct_GetById", p1);
        }

        #endregion

        #region [GroupProduct_Insert]

        public void GroupProduct_Insert(GroupProductInfo groupProduct)
        {
            var p1 = new SqlParameter("@name", groupProduct.Name);
            var p2 = new SqlParameter("@content", groupProduct.Content);
            var p3 = new SqlParameter("@image", groupProduct.Image);
            var p4 = new SqlParameter("@order", groupProduct.Order);
            var p5 = new SqlParameter("@status", groupProduct.Status);
            ExecuteStoreProcedure("sp_GroupProduct_Insert", p1, p2, p3, p4, p5);
        }

        #endregion

        #region [GroupProduct_Update]

        public void GroupProduct_Update(GroupProductInfo groupProduct)
        {
            var p0 = new SqlParameter("@id", groupProduct.Id);
            var p1 = new SqlParameter("@name", groupProduct.Name);
            var p2 = new SqlParameter("@content", groupProduct.Content);
            var p3 = new SqlParameter("@image", groupProduct.Image);
            var p4 = new SqlParameter("@order", groupProduct.Order);
            var p5 = new SqlParameter("@status", groupProduct.Status);
            ExecuteStoreProcedure("sp_GroupProduct_Update", p0, p1, p2, p3, p4, p5);
        }

        #endregion

        #region [GroupProduct_Delete]

        public void GroupProduct_Delete(int id)
        {
            var p0 = new SqlParameter("@id", id);
            ExecuteStoreProcedure("sp_GroupProduct_Delete", p0);
        }

        #endregion

        #region [GroupProduct_ActiveStatus]

        public void GroupProduct_ActiveStatus(int id, int status)
        {
            var p1 = new SqlParameter("@id", id);
            var p2 = new SqlParameter("@status", status);
            ExecuteStoreProcedure("sp_GroupProduct_ActiveStatus", p1, p2);
        }

        #endregion
    }
}